package com.insurance.modules.claim.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.insurance.common.utils.NumberUtils;
import com.insurance.modules.claim.dao.CaseImporTaskDao;
import com.insurance.modules.claim.entity.CaseImporTaskEntity;
import com.insurance.modules.claim.service.CaseImporTaskService;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.insurance.common.utils.PageUtils;
import com.insurance.common.utils.Query;


@Service("caseImporTaskService")
public class CaseImporTaskServiceImpl extends ServiceImpl<CaseImporTaskDao, CaseImporTaskEntity> implements CaseImporTaskService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<CaseImporTaskEntity> page = this.page(
                new Query<CaseImporTaskEntity>().getPage(params),
                new QueryWrapper<CaseImporTaskEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public CaseImporTaskEntity queryByCode(String code) {
        LambdaQueryWrapper<CaseImporTaskEntity> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(CaseImporTaskEntity::getCode, code);
        List<CaseImporTaskEntity> list = list(queryWrapper);
        return CollectionUtils.isEmpty(list) ? null : list.get(0);
    }

}